using System;
using System.Collections.Generic;
using System.Text;
using My.IdlConverter.Core;
using My.IdlConverter.Core.Util;

namespace My.IdlConverter.Com
{
    public class ComOverloadMethodCollision : OverloadMehodCollision
    {
        public override IDictionary<string, IList<Method>> CollisionMethods
        {
            get
            {
                IDictionary<string, IList<Method>> _collisionMethods = new Dictionary<string, IList<Method>>();

                IList<Method> methods = ArrayHelper.Copy<Method>(CacheMethods);
                while (methods.Count > 0)
                {
                    IList<Method> overloads = ArrayHelper.FindCopies<Method>(CacheMethods, methods[0], ComplierHelper.IsOverLoad);
                    if (overloads.Count <= 1)
                    {
                        methods.Remove(methods[0]);
                    }
                    else
                    {
                        if (!_collisionMethods.ContainsKey(overloads[0].Name))
                        {
                            _collisionMethods.Add(overloads[0].Name, overloads);
                        }
                        ArrayHelper.RemoveRange<Method>(methods, overloads);
                    }
                }

                return _collisionMethods;
            }
        }
        }
}
